/*
 * @Description: 
 * @Version: 0.1
 * @Autor: 许振富 zfgj201511
 * @Date: 2025-01-17 10:56:17
 * @FilePath: \stm\System\hlk_protocol\zw0906_protocol.h
 * @LastEditors: 许振富(jia)
 * @LastEditTime: 2025-01-18 15:39:26
 */
#ifndef _zw0906_protocol_
#define _zw0906_protocol_


//串口接收过程枚举
typedef enum
{
    zw0906_Head = 0,
    zw0906_LEN,
    zw0906_ENTER,
    zw0906_DATA,
    zw0906_LRC,
    zw0906_Valid,
    zw0906_TIMEOUT
} __zw0906_rec_Flag;

//接收数据缓冲区结构
typedef struct
{
    unsigned short Length;
    unsigned char enter;
    unsigned char Data[32];
} __zw0906_protocol_buf;

typedef struct
{
    volatile __zw0906_rec_Flag Flag;
    unsigned char head_buf[7];
    unsigned char count;
    unsigned short LRC;           
    __zw0906_protocol_buf Rx_Buffer; // 接收并处理完成的数据缓冲区
} __zw0906_protocol;

extern __zw0906_protocol zw0906_p;

unsigned char zw0906_protocol_Init(__zw0906_protocol* _protocol);
unsigned char zw0906_protocol_Reset(__zw0906_protocol* _protocol);
unsigned char zw0906_protocol_Receive_Byte(__zw0906_protocol* Protocol,unsigned char _Data);
unsigned char zw0906_protocol_Data_Packaging(unsigned char _flag,unsigned char _cmd,
                                           unsigned char *_Data, unsigned short _Len,
                                           unsigned char *_Pack_Buff, unsigned short *_Pack_Len);
#endif
